﻿@{
    Layout = null;
}
<!DOCTYPE html>
@model List<LeEdu.MODEL.Courses>


<html>

<head>


    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="acdcccbbbcd0ceb9da02e9cd4c87736eb0033ee4" name="csrf-token" />
    <title>
        管理后台     | 乐知教育
    </title>
    <link href="files/system/2015/06-20/102236c61b61855109.ico?6.9.3" rel="shortcut icon" />
    <script src="~/bootstrap-3.3.5-dist/jquery-2.0.0.min.js"></script>

    <link href="~/bootstrap-3.3.5-dist/bootstrap-3.3.5-dist/css/bootstrap.min.css" rel="stylesheet" />

    <script src="~/bootstrap-3.3.5-dist/bootstrap-3.3.5-dist/js/bootstrap.min.js"></script>
    <link href="~/Content/css/bootstrap.css" rel="stylesheet" />

    <link href="~/Content/css/common.css" rel="stylesheet" />

    <link href="~/Content/css/admin.css" rel="stylesheet" />

    <link href="~/Content/css/admin_v2.css" rel="stylesheet" />

    <link href="~/Content/css/es-icon.css" rel="stylesheet" />

    <script src="~/Content/utf8-net/ueditor.config.js"></script>

    <script src="~/Content/utf8-net/ueditor.all.js"></script>


    <link href="~/Content/css/main.css" rel="stylesheet" />
    @*<link href="~/Content/css/bootstrap.css" rel="stylesheet" />*@
    <link href="~/Content/css/common.css" rel="stylesheet" />
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js?6.9.3"></script>
      <script src="js/respond.min.js?6.9.3"></script>
    <![endif]-->


    <script type="text/javascript">

        //分页显示统计数据
        //定义全局变量

        var RecordCount;//全局变量  总条数
        var PageSize = 5;//全局变量 每页显示多少条数据


        //课程选项卡的变更事件
        $(function () {
            $('#kcgl').click(function() {
                $('#pull-right').empty();
                $('#xskc').html("课程管理");
               
                $('#pull-right').append("<a class=\"btn btn-success btn-sm\" href=\"\/Course\/CourseCreate\" target=\"blank\">创建课程</a>  ");
                $('#pull-right').append("<a class=\"btn btn-success btn-sm\" href=\"/course\/create?flag=isLive\" target=\"blank\">创建直播课程</a>");
               
            })

            $('#kctj').click(function () {

                //@*<script src="~/bootstrap-3.3.5-dist/jquery-2.0.0.min.js"></script>*@
                //<link href="~/bootstrap-3.3.5-dist/bootstrap-3.3.5-dist/css/bootstrap.min.css" rel="stylesheet" />
                //document.write("<script src=\"~\/bootstrap-3.3.5-dist\/jquery-2.0.0.min.js\"><\/script>");
                $('#xskc').html("课程推荐");
                $('#pull-right').html("");
                //显示下拉框
                $.post('/Course/showcollege', function (data) {
                    var str = "";
                    str += " <option value='0'>请选择</option>";
                    for (var i = 0; i < data.length; i++) {


                        str += " <option value=" + data[i].CollegeId + ">" + data[i].CollegeName + "</option>";
                    }
                    //alert(str);return
                    $('#collegetui').html(str);
                })


                //显示推荐
                $.post('/Course/showtui', function (data) {

                    $('#course_tui').html(data);
                    // alert(data)

                });
            })
            //
            $('#kctji').click(function () {
                $('#xskc').html("课程统计");
                $('#pull-right').html("");



                //加载显示统计数据
                AjaxPage(1, PageSize);
            })


        })


        //点击查询时，开始分页
        function sou() {

            AjaxPage(1, PageSize);

        }

        function AjaxPage(CurPage, PageSize) {

            //清空数据显示Table
            $('#SearchQuery_Table tbody tr').remove();
            $('#pageCount').html('0');
            $('#MainContent_AspNetPager_Msg').html(" <a disabled='disabled' style='margin-right:5px;'> 上一页</a><span class='cpb' style='margin-right:5px;'>1</span><a disabled='disabled' style='margin-right:5px;'>下一页 </a>");
            $('#CurrentPageSize').html(CurPage);//页
            //分类
            var id = $('#CID').val();
            //标题
            var title = $('#ttt').val();
            //创建者
            var creator = $('#ccc').val();
            //alert(2); return
            $.post('/Course/test', { id: id, pageSize: PageSize, pageIndex: CurPage, title: title, creator: creator }, function (data) {


                //alert(1);return
                var str = '';
                for (var i = 0; i < data.length; i++) {

                    str += "<tr>";
                    str += "<td><a href='#'><span class=\"bg-success\">" + data[i].CoursesName + "</span></a></td>";
                    str += "<td><span class=\"bg-success\">" + 0 + "</span></td>";
                    str += "<td><span class=\"bg-success\">" + 0 + "</span></td>";
                    str += "<td><span class=\"bg-success\">" + 0 + "</span></td>";
                    str += "<td><span class=\"bg-success\">" + 0 + "</span></td>";
                    str += "</tr>";
                }
                $('#SearchQuery_Table tbody').html(str);

                //总条数
                RecordCount = data.length;

                $('#pageCount').html(RecordCount);
                //alert(RecordCount);return
                //最大页数
                var maxpage = RecordCount % PageSize == 0 ? parseInt(RecordCount / PageSize) : (parseInt(RecordCount / PageSize) + 1);

                $('#MainContent_AspNetPager_Msg').html('');//分页链接
                var span = "<li><a  href='javascript:void(0)' onclick='PageIndexClick(this)' id='TopPage' pageindex='0'> 上一页</a></li>";
                var firstPage = 0;

                var pagecount = 0;//循环的次数

                if (maxpage > 5) {
                    pagecount = 5;
                } else {
                    pagecount = maxpage;
                }
                if (CurPage > 5) {
                    pagecount = CurPage;
                    var firstPage = CurPage - 5;
                    if (firstPage >= 1) {
                        span += "<li><a  href='javascript:void(0)'  onclick='CurPageSizeClick(" + firstPage + ",this)' >...</a></li>";
                    }
                }
                for (var j = firstPage + 1; j < pagecount + 1; j++) {
                    if (j == CurPage) {
                        span += "<li><a class='cpb' style='margin-right: 5px; cursor: pointer;' onclick='CurPageSizeClick(" + j + ",this)'>" + j + "</a></li>";
                    } else {
                        span += "<li><a  href='javascript:void(0)'  onclick='CurPageSizeClick(" + j + ",this)' >" + j + "</a></li>";
                    }
                }
                pagecount = pagecount + 1;
                if (maxpage >= pagecount) {
                    span += "<li><a  href='javascript:void(0)'  onclick='CurPageSizeClick(" + pagecount + ",this)' >...</a></li>";
                }
                span += "<li><a href='javascript:void(0)' onclick='PageIndexClick(this)' id='NextPage' pageindex='0'> 下一页</a></li>";
                $('#MainContent_AspNetPager_Msg').html(span);
            }
            )
        }



        //首页、上一页、下一页、尾页点击
        function PageIndexClick(obj) {
            //当前第几页
            var CurrenPageSize = $.trim($('#CurrentPageSize').html());
            if (CurrenPageSize != '') {
                CurrenPageSize = parseInt(CurrenPageSize);
            }
            //id
            var type = $(obj).attr('id');
            //首页
            if (type == 'FirstPage') {
                CurrenPageSize = 1;
                AjaxPage(CurrenPageSize, PageSize);
                $('#CurrentPageSize').html('1');
            }
                //上一页
            else if (type == 'TopPage') {
                if (CurrenPageSize > 1) {
                    CurrenPageSize = CurrenPageSize - 1;
                } else {
                    CurrenPageSize = 1;
                }
                AjaxPage(CurrenPageSize, PageSize);
                $('#CurrentPageSize').html(CurrenPageSize);
            }
                //下一页
            else if (type == 'NextPage') {
                var size = CurrenPageSize + 1;
                var maxpage = RecordCount % PageSize == 0 ? parseInt(RecordCount / PageSize) : (parseInt(RecordCount / PageSize) + 1);
                if (size <= maxpage) {
                    CurrenPageSize = CurrenPageSize + 1
                }
                AjaxPage(CurrenPageSize, PageSize);
                $('#CurrentPageSize').html(CurrenPageSize);
            }
                //尾页
            else if (type == 'LastPage') {
                CurrenPageSize = (RecordCount % PageSize == 0 ? parseInt(RecordCount / PageSize) : parseInt(RecordCount / PageSize) + 1);
                AjaxPage(CurrenPageSize, PageSize);
                $('#CurrentPageSize').html(CurrenPageSize);
            }
        }

        //页数点击
        function CurPageSizeClick(CurPage, obj) {
            $('#CurrentPageSize').html(CurPage);
            AjaxPage(CurPage, PageSize);
        }





        function soutui() {
            var collegeid = $('#collegetui').val();
            var title = $('#title').val();
            var creator = $('#creator').val();
            // alert(collegeid); return
            $.post('/Course/showtui', { id: collegeid, title: title, creator: creator }, function (data) {

                $('#course_tui').html(data);

            });
        }


    </script>

</head>


<body>

    <!-- 网页导航菜单分布视图 -->
    @Html.Partial("~/Views/Shared/HouTai_DaoHang.cshtml")

    <div class="container">

        <div class="row">
            <!-- 网页左侧菜单分布视图 -->
            @Html.Partial("~/Views/Shared/HouTai_Left_Menu_Course.cshtml")

            <div class="col-md-10">
                <div class="page-header clearfix">
                    <h1 class="pull-left" id="xskc">课程管理</h1>
                    <div id="pull-right" class="pull-right">
                        <a class="btn btn-success btn-sm" href="/Course/CourseCreate" target="blank">创建课程</a>
                        <a class="btn btn-success btn-sm" href="/course/create?flag=isLive" target="blank">创建直播课程</a>

                    </div>
                </div>

                <ul id="myTab" class="nav nav-tabs" role="tablist">
                    <li class="active" id="kcgl"><a href="#bulletin" role="tab" data-toggle="tab">课程管理</a></li>
                    <li id="kctj"><a href="#rule" role="tab" data-toggle="tab">课程推荐</a></li>
                    <li id="kctji"><a href="#forum" role="tab" data-toggle="tab">课程统计</a></li>

                </ul>
                <!-- 选项卡面板 -->
                <div id="myTabContent" class="tab-content">
                    <!-- 课程管理 -->
                    <div class="tab-pane fade in active" id="bulletin">
                        <div class="well well-sm mtl">
                            <form id="message-search-form" class="form-inline" action="/Course/Index" method="post" novalidate="">
                                <div class="form-group">
                                    <select style="max-width:150px;" class="form-control" name="CollegeID">
                                        @{

                                            List<LeEdu.MODEL.College> lst = ViewBag.lst;
                                            <option value="">全部</option>
                                            foreach (var item in lst)
                                            {

                                                <option value="@item.CollegeId">@item.CollegeName</option>
                                            }
                                        }

                                    </select>
                                </div>
                                <div class="form-group">
                                    <select class="form-control" name="Cpublish">
                                        <option value="">课程状态</option>
                                        <option value="0">未发布</option>
                                        <option value="1">已发布</option>
                                        <option value="2">已关闭</option>
                                    </select>
                                </div>


                                <div class="form-group">
                                    <input class="form-control" placeholder="标题" name="title" value="" type="text">
                                </div>
                                <div class="form-group">
                                    <input class="form-control" placeholder="创建者" name="creator" value="" type="text">
                                </div>
                                <input class="btn btn-primary" type="submit" value="搜索" />


                            </form>
                        </div>
                        <table class="table table-striped table-hover" id="course-table" style="word-break:break-all;">
                            <thead>
                                <tr>
                                    <th>编号</th>
                                    <th>名称</th>
                                    <th>连载状态</th>
                                    <th>学员数</th>
                                    <th>收入(元)</th>
                                    <th>状态</th>
                                    <th>创建者</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                @{

                                    foreach (var item in Model)
                                    {
                                        <tr id="course-tr-2">
                                            <td>@item.CoursesId</td>

                                            <td>
                                                <a href="/course/TitleManage/@item.CoursesId" target="_blank"><strong>@item.CoursesName</strong></a>


                                                <br>
                                                <span class="text-muted text-sm">

                                                    @(item.College != null ? item.College.CollegeName : "暂无")
                                                </span>

                                            </td>
                                            <td>
                                                <span class="text-info">@(item.CState == 0 ? "非连载" : item.CState == 1 ? "更新" : item.CState == 2 ? "完结" : "--")</span>
                                            </td>
                                            <td>0</td>
                                            <td><span class="money-text">@(item.CPrice)</span></td>@*等会再算哦*@
                                            <td><span class="text-success">@(item.Cpublish == 0 ? "未发布" : item.Cpublish == 1 ? "已发布" : item.Cpublish == 2 ? "关闭" : item.Cpublish == null ? "暂无" : "")</span></td>
                                            <td>
                                                <a href="javascript:;" data-toggle="modal" data-target="#modal" data-url="http://www.zhishile.com/admin/user/2">@item.CreatePeople</a>

                                                <br>
                                                <span class="text-muted text-sm">@item.CreateTime</span>
                                            </td>
                                            <td>

                                                <div class="btn-group">
                                                    <a class="btn btn-default btn-sm" href="@Url.Action("CourseCreateManage", "Course",new {id=item.CoursesId})" target="_blank">管理</a>
                                                    <a href="#" type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                                                        <span class="caret"></span>
                                                    </a>
                                                    <ul class="dropdown-menu pull-right">
                                                        <li><a class="recommend-course" href="/course/fabu/@item.CoursesId"><span class="glyphicon glyphicon-hand-up"></span> 发布课程</a></li>


                                                        <li><a class="copy-course" id="copy-course" href="/Course/tuijian/@item.CoursesId" data-type="normal"><span class="glyphicon glyphicon-plus-sign"></span> 推荐</a></li>

                                                        @*<li><a href="/course/2?previewAs=guest" target="_blank"><span class="glyphicon glyphicon-eye-open"></span> 预览：作为未购买用户</a></li>
                                                            <li><a href="/course/2?previewAs=member" target="_blank"><span class="glyphicon glyphicon-eye-open"></span> 预览：作为已购买用户</a></li>*@

                                                        <li class="divider"></li>
                                                        <li><a class="close-course" href="/course/guanbi/@item.CoursesId " data-user=" 学员"><span class="glyphicon glyphicon-ban-circle"></span> 关闭课程</a></li>
                                                        <li><a href="/course/quxiaotuijian/@item.CoursesId" title="发送发布课程(C#编程语言学习路线（一）——语言基础)通知短信"><span class="glyphicon glyphicon-envelope"></span> 取消推荐</a></li>
                                                    </ul>
                                                </div>
                                            </td>

                                        </tr>
                                    }
                                }
                            </tbody>
                        </table>
                        @if (Model != null)
                        {

                            <ul class="pagination ">
                                <li @*class="active"*@><a href="/Course/Index?pageIndex=1&&CollegeID=@(ViewBag.CollegeID)&&CValidity=@(ViewBag.Cpublish)&&title=@(ViewBag.title)&&creator=@(ViewBag.creator)">首页</a></li>
                                <li><a href="/Course/Index?pageIndex=@((ViewBag.pageIndex - 1) < 1 ? "1" : (ViewBag.pageIndex - 1))&&CollegeID=@(ViewBag.CollegeID)&&CValidity=@(ViewBag.Cpublish)&&title=@(ViewBag.title)&&creator=@(ViewBag.creator)">上一页</a></li>

                                @for (int i = 1; i <= ViewBag.pageCount; i++)
                                {
                                    <li><a href="/Course/Index?pageIndex=@i&&CollegeID=@(ViewBag.CollegeID)&&CValidity=@(ViewBag.Cpublish)&&title=@(ViewBag.title)&&creator=@(ViewBag.creator)">@i</a></li>
                                }

                                <li><a href="/Course/Index?pageIndex=@((ViewBag.pageIndex + 1) > ViewBag.pageCount ? ViewBag.pageCount  : (ViewBag.pageIndex + 1))&&CollegeID=@(ViewBag.CollegeID)&&CValidity=@(ViewBag.Cpublish)&&title=@(ViewBag.title)&&creator=@(ViewBag.creator)"><i></i>下一页</a></li>
                                <li><a href="/Course/Index?pageIndex=@ViewBag.pageCount&&CollegeID=@(ViewBag.CollegeID)&&CValidity=@(ViewBag.Cpublish)&&title=@(ViewBag.title)&&creator=@(ViewBag.creator)">尾页</a></li>
                            </ul>

                        }

                    </div>
                    <!-- 课程推荐 -->
                    <div class="tab-pane fade" id="rule">
                        <form id="message-search-form" class="form-inline well well-sm" novalidate="">
                            <div class="form-group">
                                <select style="max-width:150px;" class="form-control" name="CollegeID" id="collegetui"></select>
                            </div>
                            <div class="form-group">
                                <input class="form-control" placeholder="标题" id="title" name="title" value="" type="text">
                            </div>
                            <div class="form-group">
                                <input class="form-control" placeholder="创建者" id="creator" name="creator" value="" type="text">
                            </div>
                            <input type="button" value="搜索" class="btn btn-primary" onclick="return soutui()" />

                        </form>
                        <table class="table table-striped table-hover mtl" id="course-recommend-table">


                            <thead>
                                <tr>
                                    <th>顺序号</th>
                                    <th width="50%">课程名称</th>
                                    <th>创建者</th>
                                    <th>推荐时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody id="course_tui"></tbody>
                        </table>

                        <!-- 设置推荐课程 -->
                        <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
                             aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                                <div class="modal-content">

                                </div><!-- /.modal-content -->
                            </div><!-- /.modal -->
                        </div>
                    </div>
                    <!-- 课程统计 -->
                    <div class="tab-pane fade" id="forum">

                        <form id="message-search-form" class="form-inline well well-sm mtl">
                            <div class="form-group">
                                <select style="max-width:150px;" class="form-control" name="CollegeID" id="CID">
                                    @{

                                        List<LeEdu.MODEL.College> lst4 = ViewBag.lst;

                                        <option value="">选择课程</option>
                                        foreach (var item in lst4)
                                        {

                                            <option value="@item.CollegeId">@item.CollegeName</option>
                                        }
                                    }
                                </select>
                            </div>
                            <div class="form-group">
                                <input class="form-control" placeholder="标题" name="title" id="ttt" type="text">
                            </div>
                            <div class="form-group">
                                <input class="form-control" placeholder="创建者" name="creator" id="ccc" type="text">
                            </div>
                            <input type="button" onclick="return sou()" value="搜索">
                        </form>
                        <div class="table-responsive">
                            <table class="table table-bordered" id="SearchQuery_Table" style="word-break:break-all;text-align:center;">
                                <thead>
                                    <tr class="active">
                                        <td width="30%">课程名</td>
                                        <td>课时数</td>
                                        <td>学员人数</td>
                                        <td>完成课程人数</td>

                                        <td>课程收入(元)</td>
                                        @*<td>操作</td>*@
                                    </tr>

                                </thead>
                                <tbody></tbody>



                            </table>

                            <div class="row" style="margin-top: 15px;">
                                <div class="col-lg-12 col-sm-12 col-xs-12 col-xxs-12">
                                    <div style="font-size: 14px;">共<label style="color: #20A8D8; font-size: 14px;" id="pageCount">@ViewBag.count</label>条记录</div>

                                    <input type="hidden" id="num2" value="@ViewBag.count" />
                                </div>

                            </div>


                            <ul id="MainContent_AspNetPager_Msg" class="pagination"></ul>
                            <div class="hidden" id="CurrentPageSize">1</div>






                            @*<ul class="pagination ">
                                    <li class="active"><a href="/admin/course/data?page=1">1</a></li>
                                    <li><a href="/admin/course/data?page=2">2</a></li>
                                    <li><a href="/admin/course/data?page=3">3</a></li>

                                    <li><a href="/admin/course/data?page=2"><i class="es-icon es-icon-chevronright"></i></a></li>
                                    <li><a href="/admin/course/data?page=3">尾页</a></li>
                                </ul>*@





                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>



    <script>
        var app = {};
        app.debug = false;
        app.version = '6.9.3';
        app.httpHost = 'http://www.zhishile.com';
        app.basePath = '';
        app.theme = 'jianmo';
        app.themeGlobalScript = 'theme/global-script';
        app.jsPaths = { "common": "common", "theme": "\/themes\/jianmo\/js", "customwebbundle": "\/bundles\/customweb\/js", "customadminbundle": "\/bundles\/customadmin\/js", "topxiawebbundle": "\/bundles\/topxiaweb\/js", "topxiaadminbundle": "\/bundles\/topxiaadmin\/js", "classroombundle": "\/bundles\/classroom\/js" };
        app.crontab = '/common/crontab';
        var CKEDITOR_BASEPATH = app.basePath + '/assets/libs/ckeditor/4.6.7/';
        app.config = { "api": { "weibo": { "key": "" }, "qq": { "key": "" }, "douban": { "key": "" }, "renren": { "key": "" } }, "cloud": { "video_player": "http:\/\/cdn.staticfile.org\/GrindPlayerCN\/1.0.2\/GrindPlayer.swf", "video_player_watermark_plugin": "http:\/\/cdn.staticfile.org\/GrindPlayerCN\/1.0.2\/Watermake-1.0.3.swf", "video_player_fingerprint_plugin": "http:\/\/cdn.staticfile.org\/GrindPlayerCN\/1.0.2\/Fingerprint-1.0.1.swf" }, "loading_img_path": "\/assets\/img\/default\/loading.gif?6.9.3" };
        app.arguments = {};
        app.controller = 'course/manage';
        app.scripts = null;
        app.uploadUrl = '/file/upload';
        app.imgCropUrl = '/file/img/crop';
        app.lessonCopyEnabled = '0';
        app.mainScript = '/bundles/topxiaadmin/js/admin-app.js?6.9.3';
    </script>
    <script src="/assets/libs/seajs/seajs/2.2.1/sea.js?6.9.3"></script>
    <script src="/assets/libs/seajs/seajs-style/1.0.2/seajs-style.js?6.9.3"></script>
    <script src="/assets/libs/seajs-global-config.js?6.9.3"></script>
    <script>
        seajs.use(app.mainScript);
    </script>  <div id="modal" class="modal"></div>
    <div class="fixed-bar">
        <a href="/admin/feedback" target="_blank" class="icon-question-text feedback">
            <i class="es-icon es-icon-help"></i>
            <span>产品<br>反馈</span>
        </a>
    </div>


</body>
</html>
